package com.codingman.data.mybatis.support;

import org.apache.ibatis.builder.annotation.ProviderMethodResolver;
import org.apache.ibatis.jdbc.SQL;

public class InsertSqlProvider extends BaseSqlProviderSupport implements ProviderMethodResolver {
	public <S> String insert(S entity) {
		Class<?> entityClass = entity.getClass();
		TableInfo table = TableInfo.forClass(entityClass);
		
		SQL sql = new SQL();
		sql.INSERT_INTO(table.getName());
		
		for(String column : table.getColumns()) {
			sql.VALUES(column, "#{" + column + "}");
		}
		
		return sql.toString();
	}
}
